// pages/list/list.js
const time = require('../../utils/time');
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    imageRoot: app.globalData.imageRoot,
    // tabbar_active:1,
    height: 0,
    widHeight: 0,
    orderings: '', //排序
    currentTab: 0,
    def:'https://api.yipaiju.com/resources/images/wawa/index_1.jpg',
    fpgd: {
      sales: [
        // '不限',
        '预告中',
        '进行中',
        '已成交',
        '已暂缓',
        '已中止',
        '已结束',
        '已撤回',
      ],
      stage: [
        // '不限',
        '一轮',
        '二轮',
        '秒杀'
      ],
      stage1: [
        // '不限',
        '一拍',
        '二拍',
        '变卖'
      ],
      time: [
        // '不限',
        '住宅用房',
        '商业用房',
        '工业用房',
        '其他用房'
      ],
      itl: [
        // '不限',
        '40㎡以下',
        '40㎡-60㎡',
        '60㎡-90㎡',
        '90㎡-120㎡',
        '120㎡-144㎡',
        '144㎡以上',
      ]
    },
    sf: {
      cf: [
        // '不限',
        '有',
        '无'
      ],
      stl: [
        // '不限',
        '一房',
        '两房',
        '三房',
        '四房'
      ],
      face: [
        // '不限',
        '东',
        '西',
        '南',
        '北',
        '东南',
        '东北',
        '西南',
        '西北'
      ],
      itl: [
        // '不限',
        '40㎡以下',
        '40㎡-60㎡',
        '60㎡-90㎡',
        '90㎡-120㎡',
        '120㎡-144㎡',
        '144㎡以上',
      ]
    },
    price: [
      // '不限',
      '100万以内',
      '100-200万',
      '200-300万',
      '300-500万',
      '500万以上'
    ],
    inToggle1: false,
    inToggle2: false,
    inToggle3: false,
    inToggle4: false,
    fpmyl: false,
    zkmyl: false,
    fp: [],
    zk: [],
    option: [{
        text: '默认排序',
        value: 0
      },
      {
        text: '价格最高',
        value: 1
      },
      {
        text: '价格最低',
        value: 2
      },
      {
        text: '最新发布',
        value: 3
      },
      {
        text: '折扣率最高',
        value: 4
      },
    ],
    value: 0,
    checks: [{
        check: []
      },
      {
        check: []
      }, {
        check: []
      }, {
        check: []
      }, {
        check: []
      }
    ],
    state: {
      province: false,
      city: false,
      area: false
    },
    val: {
      province: null
    },
    range: {},
    lts: null,
    gts: null,
    dataarealist: null, //区域数据
    datapricelist: null, //价格数据
    datamorelist: null, //更多数据
    datazqmorelist: null, //折扣房更多数据
    value2: null, //用于重置选中状态
    page_token: 0,
    deleData: [],
    loading:true
  },
  inCancel() {
    this.setData({
      dataarealist: null
    })
    var data = {
      page_size: 10,
      page_token: 0,
      province: '',
      city: '',
      district: '',
    }
    this.api(data)
  },
  getUserInfo(e) { //页面授权
    var that = this;
    if (e.detail.errMsg == "getUserInfo:ok") {
      let data = {
        encryptedData: e.detail.encryptedData,
        iv: e.detail.iv,
        appid: app.globalData.appid,
      }
      getApp().ports.loginInfo({
        data
      }).then((res) => {
        wx.setStorageSync('userInfo', res.data)
        that.setData({
          userInfo: false
        })
      }).catch(() => {
        console.error('出啥错了？');
      });
    } else {
      return
    }
  },
  IsExist(fileName) { //判断是否是图片
    // var fileName = 'None?x-oss-process=image/resize,p_25'
    //用文件名name后缀判断文件类型，可用size属性判断文件大小不能超过500k ， 前端直接判断的好处，免去服务器的压力。 
    if (!/\.(jpg|jpeg|png|GIF|JPG|PNG)$/.test(fileName)) {
      return false;
    } else {
      return true;
    }
  },
  api(data) { //请求
    var statuss = ['待审核', '待上架', '出售中', '已出售'];
    // data.province = '广东省'
    // data.page_size = 100
    var that = this;
    // wx.showLoading({
    //   title: '加载中',
    // })
    if (that.data.title) data.title = that.data.title;
    var status = Number(that.data.currentTab);
    if (status == 0) {
      getApp().ports.api1({
        data: data
      }).then((res) => {
        var res = res.data;
        if (data.page_token >= 1) {
          // that.onShowImg(res)
          res.results.forEach(item => {
            item.url = "../details/details?status=0&&id=" + item.id
            switch (item.stage) {
              case '变卖':
                item.stage = '秒杀'
                break;
              case '一拍':
                item.stage = '一轮'
                break;
              case '二拍':
                item.stage = '二轮'
                break;
            }
            item.tags = [{
              name: item.builtUpAreaSquareCentimeter + '㎡'
            }, {
              name: item.discountRate + '折'
            }, {
              name: item.stage
            }]
            item.marketPriceYuan = Math.floor((item.marketPriceYuan / 10000));
            item.priceYuan = Math.floor((item.priceYuan / 10000));
            item.dealPrice = Math.floor((item.dealPrice / 10000));
            item.estimatePriceYuan = Math.floor((item.estimatePriceYuan / 10000));
            item.time = (app.timeFormat(item.startTime)||'') + '-' + (app.timeFormat(item.endTime)||'')
            that.data.fp.results.push(item)
          });
          res.results = that.data.fp.results
        } else {
          // that.onShowImg(res)
          res.results.forEach(item => {
            switch (item.stage) {
              case '变卖':
                item.stage = '秒杀'
                break;
              case '一拍':
                item.stage = '一轮'
                break;
              case '二拍':
                item.stage = '二轮'
                break;
            }
            item.url = "../details/details?status=0&&id=" + item.id
            item.tags = [{
              name: item.builtUpAreaSquareCentimeter + '㎡'
            }, {
              name: item.discountRate + '折'
            }, {
              name: item.stage || ''
            }]
            item.marketPriceYuan = Math.floor((item.marketPriceYuan / 10000));
            item.dealPrice = Math.floor((item.dealPrice / 10000));
            item.priceYuan = Math.floor((item.priceYuan / 10000));
            item.estimatePriceYuan = Math.floor((item.estimatePriceYuan / 10000));
            item.time = (app.timeFormat(item.startTime)||'') + '-' + (app.timeFormat(item.endTime)||'')
          })
        }
        that.setData({
          fp: res,
          loading:false
        })
        // wx.hideLoading({
        //   success: (res) => {},
        // })
      }).catch(() => {
        console.error('出啥错了？');
      });
    } else {
      data.status = 2
      getApp().ports.api5({
        data: data
      }).then((res) => {
        var res = res.data;
        if (data.page_token >= 1) {
          // that.onShowImg(res)
          res.results.forEach(item => {
            item.status = statuss[item.status]
            item.url = "../details/details?status=1&&id=" + item.id
            item.uploadTime = app.timeFormat(item.uploadTime, true)
            that.data.zk.results.push(item)
          })
          res.results = that.data.zk.results
        } else {
          // that.onShowImg(res)
          res.results.forEach(item => {
            item.status = statuss[item.status]
            item.uploadTime = app.timeFormat(item.uploadTime, true)
            item.url = "../details/details?status=1&&id=" + item.id
          })
        }
        that.setData({
          zk: res,
          loading:false
        })
      }).catch(() => {
        console.error('出啥错了？');
      });
      // wx.hideLoading({
      //   success: (res) => {},
      // })
    }
  },
  onReachBottom() { //上拉加载更多
    var that = this;
    var active = that.data.currentTab;
    var dataarealist = that.data.dataarealist;
    var datapricelist = that.data.datapricelist;
    var datamorelist = that.data.datamorelist;
    var type = [that.data.fp, that.data.zk];
    var myl = ['fpmyl', 'zkmyl'];
    //检查是否还有数据可以加载
    var total_size = type[active].total;
    var size = type[active].results.length;
    var page_token = that.data.page_token += 1
    //如果还有，则继续加载
    if (total_size > size) {
      var data = {
        page_size: 10,
        page_token: page_token
      }
      that.orderings(data); //堆叠条件
      if (that.data.orderings) { //添加排序字段
        data.orderings = that.data.orderings
      }
      that.api(data)
      //如果没有了，则停止加载，显示没有更多内容了
    } else {
      var myls = myl[active]
      that.setData({
        [myls]: true,
      })
    }
    that.setData({
      page_token: page_token
    })
  },
  inEnter(e) {
    var that = this;
    var ordertype = that.data.currentTab;
    that.data.checks.forEach(item => {
      item.check = []
    })
    Object.assign(that.data,{
      datamorelist: null,
      datapricelist: null,
      page_token: 0,
      orderings: '',
    })
    that.setData({
      checks: that.data.checks,
      value: null
    })
    var district = (e.detail.area.value == '全市' ? '' : e.detail.area.value);
    var city = (e.detail.city.value == '全省' ? '' : e.detail.city.value);
    var province = (e.detail.province.value == '全国' ? '' : e.detail.province.value);
    var data = {
      ordertype: ordertype,
      province: province,
      city: city,
      district: district,
      page_token: 0
    }
    that.setData({
      dataarealist: data
    })
    var currentTab = that.data.currentTab;
    that.setData({
      fp: []
    })
    that.api(data)
    that.selectComponent('#item1').toggle();
  },
  getPrice(e) { //最小到最大价格
    var that = this;
    var type = e.currentTarget.dataset.type;
    var range = that.data.range;
    if (type == 'min') {
      range.min = e.detail.value;
    } else if (type = 'max') {
      range.max = e.detail.value;
    }
    that.setData({
      range: range
    })
  },
  orderings(data) { //堆叠条件
    let that = this;
    console.log(data,'--===')
    if (that.data.datapricelist) {
      data['priceMax'] = that.data.datapricelist.lts;
      data['priceMin'] = that.data.datapricelist.gts
      // data['price[lt]'] = that.data.datapricelist.lts;
      // data['price[gt]'] = that.data.datapricelist.gts
    }
    if (that.data.datamorelist) {
      // data['area[lt]'] = that.data.datamorelist.lts;
      // data['area[gt]'] = that.data.datamorelist.gts;
      data['areaMax'] = that.data.datamorelist.lts;
      data['areaMin'] = that.data.datamorelist.gts;
      if (that.data.datamorelist.statusArr) data['statusArr'] = that.data.datamorelist.statusArr;
      if (that.data.datamorelist.stageArr) data['stageArr'] = that.data.datamorelist.stageArr;
      if (that.data.datamorelist.houseTypeArr) data['houseTypeArr'] = that.data.datamorelist.houseTypeArr
    }
    if (that.data.dataarealist) {
      data['province'] = that.data.dataarealist.province;
      data['city'] = that.data.dataarealist.city;
      data['district'] = that.data.dataarealist.district
    }
    if (that.data.datazqmorelist) {
      // data['area[lt]'] = that.data.datazqmorelist.lts;
      // data['area[gt]'] = that.data.datazqmorelist.gts;
      data['areaMax'] = that.data.datazqmorelist.lts;
      data['areaMin'] = that.data.datazqmorelist.gts;
      data['elevator'] = that.data.datazqmorelist.elevator;
      if (that.data.datazqmorelist.bedroom) data['bedroom'] = that.data.datazqmorelist.bedroom;
      data['orientation'] = that.data.datazqmorelist.orientation
    }
    return data
  },
  sort(e) { //排序
    var that = this;
    var value = Number(e.detail);
    var currentTab = that.data.currentTab;
    var type = [that.data.fp, that.data.zk];
    var sortPrice;
    switch (value) {
      case 0:
        let dataM = {
          page_token: 0,
          page_size: 10
        };
        that.data.orderings = null
        that.orderings(dataM)
        that.api(dataM)
        break;
      case 1:
        let data = {
          orderings: '-price_yuan',
          page_token: 0,
          page_size: 10
        }
        that.orderings(data)
        that.data.orderings = '-price_yuan'
        that.api(data)
        // type[currentTab].results =  type[currentTab].results.sort(that.sortBy('price_yuan', false))
        break;
      case 2:
        var datas = {
          orderings: 'price_yuan',
          page_token: 0,
          page_size: 10
        }
        that.orderings(datas)
        that.data.orderings = 'price_yuan'
        that.api(datas)
        // type[currentTab].results =  type[currentTab].results.sort(that.sortBy('price_yuan'));
        break;
      case 3:
        if (currentTab == 0) {
          var dataT = {
            page_token: 0,
            page_size: 10,
            orderings: '-start_time'
          }
          that.orderings(dataT)
          that.data.orderings = '-start_time'
          that.api(dataT)
          // that.data.fp.results =  app.ReverseRankingDate( that.data.fp.results,'start_time')
        } else {
          that.data.zk.results = app.ReverseRankingDate(that.data.fp.results, 'upload_time')
        }
        break;
      case 4:
        var dataR = {
          page_token: 0,
          page_size: 10,
          orderings: 'discount_rate'
        }
        that.orderings(dataR)
        that.data.orderings = 'discount_rate'
        that.api(dataR)
        // type[currentTab].results = type[currentTab].results.sort(that.sortBy('discount_rate',true));
        break;
    }
    if (currentTab == 0) {
      that.setData({
        fp: that.data.fp,
        page_token: 0
      })
    } else {
      that.setData({
        zk: that.data.zk,
        page_token: 0
      })
    }
  },
  dateData(property, bol) { //最新排序
    return function (a, b) {
      var value1 = a[property];
      var value2 = b[property];
      if (bol) {
        // 升序
        return Date.parse(value1) - Date.parse(value2);
      } else {
        // 降序
        return Date.parse(value2) - Date.parse(value1)
      }
    }
  },
  sortBy(attr, rev) { //价格排序
    //第二个参数没有传递 默认升序排列
    if (rev == undefined) {
      rev = 1;
    } else {
      rev = (rev) ? 1 : -1;
    }

    return function (a, b) {
      a = a[attr];
      b = b[attr];
      if (a < b) {
        return rev * -1;
      }
      if (a > b) {
        return rev * 1;
      }
      return 0;
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    // app.globalData.indexUrl = this;
    wx.hideShareMenu({
      menus: ['shareAppMessage', 'shareTimeline']
    })
    that.setData({
      page_token: 0,
      active_color: app.globalData.active_color
    })
    wx.getSetting({
      success: (res) => {
        let authSetting = res.authSetting
        if (authSetting['scope.userLocation']) {
          wx.getLocation({
            type: 'gcj02',
            success(res) {
              let data = {
                latitude: res.latitude,
                longitude: res.longitude
              }
              getApp().ports.apicitydsec({
                data
              }).then(async (res) => {
                let data = {
                  province: res.data.province,
                  city: res.data.city,
                  page_token: 0,
                  page_size: 10,
                }
                if (that.data.currentTab == 0) {
                  data.district = res.data.district
                } else {
                  data.district = ''
                }
                Object.assign(that.data,{
                  dataarealist: data
                })
                await that.api(data);
              }).catch(() => {
                console.error('获取省市区失败！')
              })
            }
          })
        } else {
          var data = {
            page_size: 10,
            page_token: 0
          }
          that.setData({
            dataarealist: null
          })
          that.api(data);
        }
      }
    })
  },
  onShowImg(list){
    // let list = this.data.list  // 获取原数据
    console.log(list)
    for (let i in list.results){
      wx.createIntersectionObserver().relativeToViewport({bottom: 20}).observe('.item-'+ i, (ret) => {
        if (ret.intersectionRatio > 0){
          list.results[i].show = true 
        }
        // this.setData({ // 更新数据
        //   list
        // })
      })
    }
  },
  onClickNav(e) {},

  onClickItem({
    detail = {}
  }) {
    const activeId = this.data.activeId === detail.id ? null : detail.id;
    this.setData({
      activeId
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getTabBar().init();
    getApp().ports.getInfo({}).then((res) => {
      if (res.data.nickname) { //判断是否授用户信息
        app.globalData.login = false
      } else {
        app.globalData.login = true
      }
    }).catch(() => {
      console.error("获取自身信息出错！")
    })
    this.setData({
      login: app.globalData.login
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    var data = {
      page_size: 10,
      page_token: 0
    }
    Object.assign(this.data,{
      page_token: 0
    })
    this.orderings(data)
    this.api(data);
    setTimeout(() => {
      wx.stopPullDownRefresh()
    }, 1000)
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  areaReset(e) {
    let that = this;
    that.data.checks.forEach(item => {
      item.check = []
    })
    that.setData({
      dataarealist: null,
      datamorelist: null,
      datapricelist: null,
      page_token: 0,
      orderings: '',
      checks: that.data.checks,
      value: null
    })
    var data = {
      page_size: 10,
      page_token: 0
    }
    that.api(data)
    that.selectComponent('#item1').toggle();
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.reset();
    let dataarealist = that.data.dataarealist;
    Object.assign(that.data, {
      datapricelist: null, //清除价格区间
      datazqmorelist: null,
      datamorelist: null, //清楚更多数据，因为两个参数不同，为了统一全部清除
      orderings: '', //清除接口排序字段
      page_token: 0
    });
    that.setData({
      currentTab: e.detail.index,
    });
    if (dataarealist) {
      if (that.data.currentTab == 0) {
        var data = {
          province: dataarealist.province,
          city: dataarealist.city,
          district: dataarealist.district,
          page_size: 10,
          page_token: 0
        }
      } else {
        var data = {
          // province: dataarealist.province,
          // city: dataarealist.city,
          // district: dataarealist.district,
          page_size: 10,
          page_token: 0
        }
      }
    } else {
      var data = {
        page_size: 10,
        page_token: 0
      };
    }
    that.api(data)
  },
  searchInput(e) {
    this.setData({
      title: e.detail
    })
  },
  search: function (e) {
    let that = this;
    let data = {
      page_size: 10,
      page_token: 0
    }
    var statuss = ['待审核', '待上架', '出售中', '已出售'];
    that.data.page_token = 0
    that.orderings(data);
    // data.district = ''
    // data.city = '';
    this.api(data)
    // console.log(data)
    // this.api(data)
  },
  bindRegionChange: function (e) {
    this.setData({
      region: e.detail.value
    })
  },
  onSwitch1Change({
    detail
  }) {
    this.setData({
      switch1: detail
    });
  },

  onSwitch2Change({
    detail
  }) {
    this.setData({
      switch2: detail
    });
  },
  check(e) {
    var that = this;
    var status = e.currentTarget.dataset.status;
    var index = e.currentTarget.dataset.index;
    var checks = that.data.checks;
    // var check = checks[status].check = e.currentTarget.dataset.index;

    console.log(checks[status].check, '===============')
    var pos = checks[status].check.indexOf(index)

    if(pos > -1){
      checks[status].check.splice(pos, 1)
    }else{
      if (that.data.currentTab == 0) {
        checks[status].check.push(index)
      }else{
        if (status != 4) {
          checks[status].check = []
        }
        checks[status].check.push(index)
      }
      
    }
    
    
    // console.log(checks[status].check, '==============')
    that.setData({
      checks: checks
    })

  },
  reset(e) {
    var that = this;
    that.data.checks.forEach(item => {
      item.check = []
    })
    that.setData({
      datamorelist: null,
      checks: that.data.checks
    })
    that.selectComponent('#item3').toggle();
  },
  navTo: function (e) { //跳转
    var url = e.currentTarget.dataset.url;
    var status = e.currentTarget.dataset.status;
    if (status == '优选') {
      status = 0
    } else {
      status = 1
    }
    wx.navigateTo({
      url: url + '?status=' + status
    })
  },
  fpPrice(e) { //筛选价格
    var that = this;
    that.setData({
      page_token: 0,
      page_size: 10
    })
    var status = e.currentTarget.dataset.status;
    var currentTab = that.data.currentTab;
    var checks = that.data.checks;
    var dataarealist = that.data.dataarealist;
    var datamorelist = that.data.datamorelist;
    var lt = 9999999999;
    var gt = 0;
    var sales = '';

    let checkcOrr = checks[0].check.sort()
    if (checkcOrr.length > 0 ){
      gt = that.priceGtLt(checkcOrr[0], 1)
      lt = that.priceGtLt(checkcOrr[checkcOrr.length - 1], 2)
    }
    
    let datapricetemp = {
      lts: lt,
      gts: gt
    }
    // that.setData({
    //   datapricelist: datapricetemp
    // })
    Object.assign(that.data, {
      datapricelist: datapricetemp
    })
    var data = {
      page_size: 10,
      page_token: 0
    };
    that.orderings(data)
    that.api(data)
    that.selectComponent('#item2').toggle();
  },

  priceGtLt(index, type){
    let that = this;
    var lt = 9999999999;
    var gt = 0;
    if (index == 0) {
      if (that.data.currentTab == 1) {
        gt = 0;
        lt = 100;
      } else {
        gt = 0;
        lt = 1000000;
      }
    } else if (index == 1) {
      if (that.data.currentTab == 1) {
        gt = 100;
        lt = 200;
      } else {
        gt = 1000000;
        lt = 2000000;
      }
    } else if (index == 2) {
      if (that.data.currentTab == 1) {
        gt = 200;
        lt = 300;
      } else {
        gt = 2000000;
        lt = 3000000;
      }
    } else if (index == 3) {
      if (that.data.currentTab == 1) {
        gt = 300;
        lt = 500;
      } else {
        gt = 3000000;
        lt = 5000000;
      }
    } else if (index == 4) {
      if (that.data.currentTab == 1) {
        gt = 500;
        lt = 9999999999;
      } else {
        gt = 5000000;
        lt = 9999999999
      }
    }
    return type == 1 ? gt : lt;
  },
  getStatusArr(arr, iarr){
    let str = '';
    if (iarr.length > 0){
      iarr.forEach(i=>{
        str += arr[i] + ','
      })
    }
    if (str != '') {
      str = str.substr(0, str.length-1)
    }
    return str;
  },
  
  areaGtLt(index, type){
    let that = this;
    var lt = 9999999999;
    var gt = 0;
    if (index == 0) {
      gt = 0;
      lt = 40;
    } else if (index == 1) {
      gt = 40;
      lt = 60;
    } else if (index == 2) {
      gt = 60;
      lt = 90;
    } else if (index == 3) {
      gt = 90;
      lt = 120;
    } else if (index == 4) {
      gt = 120;
      lt = 144;
    } else if (index == 5) {
      gt = 144;
    }
    return type == 1 ? gt : lt;
  },
  fpMore(e) { //优选更多筛选
    var that = this;
    that.setData({
      page_token: 0,
      page_size: 10
    })
    var fpgd = that.data.fpgd;
    var checks = that.data.checks;
    var dataarealist = that.data.dataarealist;
    var datapricelist = that.data.datapricelist;

    // var sales = (fpgd.sales[checks[1].check] == '不限' ? '' : fpgd.sales[checks[1].check]);
    var sales = that.getStatusArr(fpgd.sales, checks[1].check);

    // var stage = (fpgd.stage[checks[2].check] == '不限' ? '' : fpgd.stage[checks[2].check])
    var stage = that.getStatusArr(fpgd.stage1, checks[2].check);

    // var houseType = (fpgd.time[checks[3].check] == '不限' ? '' : fpgd.time[checks[3].check]);
    var houseType = that.getStatusArr(fpgd.time, checks[3].check);

    var lt = 9999999999;
    var gt = 0;
    let checkcOrr = checks[4].check.sort()
    if (checkcOrr.length > 0 ){
      gt = that.areaGtLt(checkcOrr[0], 1)
      lt = that.areaGtLt(checkcOrr[checkcOrr.length - 1], 2)
    }

    let datamoretemp = {
      lts: lt,
      gts: gt,
      statusArr: sales,
      stageArr: stage,
      houseTypeArr: houseType,
    }
    // that.setData({
    //   datamorelist: datamoretemp
    // })
    Object.assign(that.data, {
      datamorelist: datamoretemp
    })
    let data = {
      page_token: 0,
      page_size: 10
    }
    that.orderings(data)
    that.api(data)
    that.selectComponent('#item3').toggle();
  },
  zkMore(e) { //折扣更多筛选
    var that = this;
    that.setData({
      page_token: 0,
      page_size: 10
    })
    var sf = that.data.sf;
    var currentTab = that.data.currentTab;
    var dataarealist = that.data.dataarealist;
    var datapricelist = that.data.datapricelist;
    var checks = that.data.checks;
    // var cf = (sf.cf[checks[1].check] == '不限' ? '' : sf.cf[checks[1].check]); //elevator有无电梯
    var cf = that.getStatusArr(sf.cf, checks[1].check);
    var stls = [1, 2, 3, 4];
    // var stl = (stls[checks[2].check] == '不限' ? '' : stls[checks[2].check]) //bedroom房间数量
    var stl = that.getStatusArr(stls, checks[2].check);
    // var face = (sf.face[checks[3].check] == '不限' ? '' : sf.face[checks[3].check]); //orientation房间朝向
    var face = that.getStatusArr(sf.face, checks[3].check);

    var lt = 9999999999;
    var gt = 0;
    let checkcOrr = checks[4].check.sort()
    if (checkcOrr.length > 0 ){
      gt = that.areaGtLt(checkcOrr[0], 1)
      lt = that.areaGtLt(checkcOrr[checkcOrr.length - 1], 2)
    }
    
    let datazqmorelistTemp = {
      lts: lt,
      gts: gt,
      elevator: cf,
      bedroom: stl,
      orientation: face
    }
    // that.setData({
    //   datazqmorelist: datazqmorelistTemp
    // })
    Object.assign(that.data, {
      datazqmorelist: datazqmorelistTemp
    });
    let data = {
      page_token: 0,
      page_size: 10
    }
    that.orderings(data)
    that.api(data)
    that.selectComponent('#item3').toggle();
  },
  preventdefault: function () {}
})